<?php

namespace app\model\main;

use linkphp\Application;

class Register
{

    public function accountExists()
    {
        if(Application::db()
            ->table('lp_user')
            ->field('id')
            ->where("user_name = '" . Application::input('post.account') . "'")
            ->find()){
            return true;
        }
        return false;
    }

    public function register()
    {
        if($this->accountExists()){
            return false;
        }
        $data['user_name'] = Application::input('post.account');
        $data['pass_word'] = md5(md5(Application::input('post.password')));
        $data['reg_time'] = date('Y-m-d H:i:s',time());
        return Application::db()
            ->table('lp_user')
            ->insert($data);
    }

}